package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.sc.nft.entity.BoxItem;
import com.sc.nft.entity.vo.BoxCollectionEquityVO;
import com.sc.nft.entity.vo.BoxDigitalCollectionVO;
import com.sc.nft.entity.vo.BoxItemVO;
import com.sc.nft.mapper.BoxItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 盲盒子项表(sc_box_item)数据DAO
 *
 * @author zxy
 * @since 2022-06-03 01:43:54
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class BoxItemDao extends ServiceImpl<BoxItemMapper, BoxItem> {


    /**
     * 根据盲盒Id查询藏品
     * @param boxId
     * @return
     */
    public List<BoxDigitalCollectionVO> getDigitalCollections(Long boxId){
        return baseMapper.getDigitalCollections(boxId);
    }


    public List<BoxItem> getBoxItem(Long boxId){
        LambdaQueryWrapper<BoxItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BoxItem::getBoxId,boxId);
        return list(wrapper);
    }


    /**
     * 根据盲盒Id查询藏品
     * @param boxId
     * @return
     */
    public List<BoxItemVO> getBoxItemVO(Long boxId){
        return  baseMapper.getBoxItem(boxId);
    }

    public List<BoxCollectionEquityVO> getBoxItemByBoxId(Long boxId){
        return  baseMapper.getBoxItemByBoxId(boxId);
    }

    public void clearItem(Long boxId){
        LambdaUpdateWrapper<BoxItem> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(BoxItem::getBoxId,boxId);
        remove(wrapper);
    }


}